package cn.sciento.farm.devicemanager.gateway.lorawan.grpc;

import cn.sciento.farm.devicemanager.lorawan.*;

import java.util.Iterator;

/**
 * @author wumu
 * @version V1.0
 * @date 9/15/18
 * @time 7:03 PM
 */
public interface LoraWanDeviceService {
    // create creates the given device.
    void create(CreateDeviceRequest request);

    // get returns the device matching the given DevEUI.
    GetDeviceResponse get(GetDeviceRequest request);

    // list returns the available devices.
    ListDeviceResponse list(ListDeviceRequest request);

    // delete deletes the device matching the given DevEUI.
    int delete(DeleteDeviceRequest request);

    // updateById updates the device matching the given DevEUI.
    void update(UpdateDeviceRequest request);

    // CreateKeys creates the given device-keys.
    void createKeys(CreateDeviceKeysRequest request);

    // GetKeys returns the device-keys for the given DevEUI.
    GetDeviceKeysResponse getKeys(GetDeviceKeysRequest request);

    // updateKeys updates the device-keys.
    void updateKeys(UpdateDeviceKeysRequest request);

    // deleteKeys deletes the device-keys for the given DevEUI.
    void deleteKeys(DeleteDeviceKeysRequest request);

    // Activate (re)activates the device (only when ABP is set to true).
    void Activate(ActivateDeviceRequest request);

    // getActivation returns the current activation details of the device (OTAA and ABP).
    GetDeviceActivationResponse getActivation(GetDeviceActivationRequest request);

    // getRandomDevAddr returns a random DevAddr taking the NwkID prefix into account.
    GetRandomDevAddrResponse getRandomDevAddr(GetRandomDevAddrRequest request);

    // streamFrameLogs streams the uplink and downlink frame-logs for the given DevEUI.
    //   * These are the raw LoRaWAN frames and this endpoint is intended for debugging only.
    //   * This endpoint does not work from a web-browser.
    Iterator<StreamDeviceFrameLogsResponse> streamFrameLogs(StreamDeviceFrameLogsRequest request);

    // streamEventLogs stream the device events (uplink payloads, ACKs, joins, errors).
    //   * This endpoint is intended for debugging only.
    //   * This endpoint does not work from a web-browser.
    void streamEventLogs(StreamDeviceEventLogsRequest request);
}
